from django.db import models
from dingxiang.utils.models import BaseModel
# Create your models here.

# 科普文章方向
class SciencePopularizationDirection(BaseModel):
    # 这里可以添加科普文章方向相关的字段
    name = models.CharField(max_length=100, verbose_name="方向名称")

    def __str__(self):
        return self.name
    class Meta():
        db_table = 'science_popularization_direction'
        verbose_name_plural = '科普文章方向'

# 科普文章内容
class PopularScienceArticle(BaseModel):
    title = models.CharField(max_length=255, verbose_name="标题")
    content = models.TextField(verbose_name="内容")
    author = models.CharField(max_length=255, verbose_name="作者")
    publish_date = models.DateField(auto_now_add=True, null=True, verbose_name="发表日期")
    image = models.ImageField(upload_to='popular_science/', null=True, blank=True, verbose_name="图片")
    external_links = models.URLField(max_length=255, blank=True, null=True, verbose_name="外部链接")
    copyright = models.CharField(max_length=255, blank=True, null=True, verbose_name="版权信息")
    recommend_home = models.BooleanField(default=False,verbose_name='是否推荐首页栏目', null=True)

    class Meta:
        db_table = 'popular_science_article'
        verbose_name_plural = '科普文章'

    def __str__(self):
        return self.title